package com.jctrip.hotel.route.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jctrip.hotel.common.annotation.RedisLimitAnnotation;
import com.jctrip.hotel.route.model.param.*;
import com.jctrip.hotel.route.model.result.*;
import com.jctrip.hotel.route.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 渠道接口3.0 接口类
 */
@Slf4j
@Api(tags = "route-openapi-3.0")
@RestController
@RequestMapping("/route")
public class RouteOpenApiController {

    @Autowired
    private GetHotelIdListService getHotelIdListService;

    @Autowired
    private GetHotelInformationService getHotelInformationService;

    @Autowired
    private GetHotelRoomTypeService getHotelRoomTypeService;

    @Autowired
    private GetHotelRoomStatusService getHotelRoomStatusService;

    @Autowired
    private PostOrderService postOrderService;

    @Autowired
    private CancelOrderService cancelOrderService;

    @Autowired
    private GetOrderInfoService getOrderInfoService;

    @Autowired
    private UpdateOrderService updateOrderService;

    @Autowired
    private CheckPriceAndCountService checkPriceAndCountService;

    @Autowired
    private GetHotelPictureService getHotelPictureService;

    @RequestMapping(value = "/getHotelIdList", method = RequestMethod.POST)
    @ApiOperation(value = "getHotelIdList", notes = "获取酒店ID列表接口")
    @RedisLimitAnnotation(key = "hotel-list")
    @ApiOperationSupport(order = 1)
    public Result<GetHotelIdListResult> getHotelIdList(
            @RequestBody GetHotelIdListParam param) {
        return Result.ok(getHotelIdListService.execute(param));
    }

    @RequestMapping(value = "/getHotelInformation", method = RequestMethod.POST)
    @ApiOperation(value = "getHotelInformation", notes = "获取酒店基础信息接口")
    @RedisLimitAnnotation(key = "hotel-info")
    @ApiOperationSupport(order = 2)
    public Result<GetHotelInformationResult> getHotelInformation(
            @RequestBody GetHotelInformationParam param) {
        return Result.ok(getHotelInformationService.execute(param));
    }

    @RequestMapping(value = "/getHotelRoomType", method = RequestMethod.POST)
    @ApiOperation(value = "getHotelRoomType", notes = "获取酒店房型接口")
    @RedisLimitAnnotation(key = "room-type")
    @ApiOperationSupport(order = 3)
    public Result<GetHotelRoomTypeResult> getHotelRoomType(
            @RequestBody GetHotelRoomTypeParam param) {
        return Result.ok(getHotelRoomTypeService.execute(param));
    }

    @RequestMapping(value = "/getHotelRoomStatus", method = RequestMethod.POST)
    @ApiOperation(value = "getHotelRoomStatus", notes = "获取酒店房态接口")
    @RedisLimitAnnotation(key = "room-status")
    @ApiOperationSupport(order = 4)
    public Result<GetHotelRoomStatusResult> getHotelRoomStatus(
            @RequestBody GetHotelRoomStatusParam param) {
        return Result.ok(getHotelRoomStatusService.execute(param));
    }

    @RequestMapping(value = "/postOrder", method = RequestMethod.POST)
    @ApiOperation(value = "postOrder", notes = "下单接口")
    @ApiOperationSupport(order = 5)
    public Result<PostOrderResult> postOrder(
            @RequestBody PostOrderParam param) {
        return Result.ok(postOrderService.execute(param));
    }

    @RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
    @ApiOperation(value = "cancelOrder", notes = "取消订单接口")
    @ApiOperationSupport(order = 6)
    public Result<CancelOrderResult> cancelOrder(
            @RequestBody CancelOrderParam param) {
        return Result.ok(cancelOrderService.execute(param));
    }

    @RequestMapping(value = "/getOrderInfo", method = RequestMethod.POST)
    @ApiOperation(value = "getOrderInfo", notes = "获取订单信息接口")
    @ApiOperationSupport(order = 7)
    public Result<GetOrderInfoResult> getOrderInfo(
            @RequestBody GetOrderInfoParam param) {
        return Result.ok(getOrderInfoService.execute(param));
    }

    @RequestMapping(value = "/updateOrder", method = RequestMethod.POST)
    @ApiOperation(value = "updateOrder", notes = "更新订单接口")
    @ApiOperationSupport(order = 8)
    public Result<UpdateOrderResult> updateOrder(
            @RequestBody UpdateOrderParam param) {
        return Result.ok(updateOrderService.execute(param));
    }

    @RequestMapping(value = "/checkPriceAndCount", method = RequestMethod.POST)
    @ApiOperation(value = "checkPriceAndCount", notes = "下单前房态校验接口")
    @ApiOperationSupport(order = 9)
    public Result<CheckPriceAndCountResult> checkPriceAndCount(
            @RequestBody CheckPriceAndCountParam param) {
        return Result.ok(checkPriceAndCountService.execute(param));
    }

    @RequestMapping(value = "/getHotelPicture", method = RequestMethod.POST)
    @ApiOperation(value = "getHotelPictrue", notes = "获取酒店图片")
    @ApiOperationSupport(order = 10)
    public Result<GetHotelPictureResult> getHotelPicture(@RequestBody GetHotelPictureParam param) {
        return Result.ok(getHotelPictureService.execute(param));
    }
}
